<?php
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if( $detect->isMobile() )
{
	include('step4_mobile.php');
	return;
}

JHtml::_('behavior.keepalive');
//JHtml::_('behavior.formvalidation');
$sess=JFactory::getSession();
$dat=$sess->get("regs1.data");

if($dat){
	$db=JFactory::getDbo();
	$db->setQuery("SELECT id FROM #__users WHERE email=".$db->quote($dat['email']));
	$id_user=$db->loadResult();
}

if(!$id_user)
	jexit("step4 N/A");

if($dat=$sess->get("regs2.data"))
	extract($dat);//all keys become variables
?>
<style type="text/css">
	.w115{width: 115px}
	.ml30{margin-left: 30px}
	.nohand{cursor:default}
</style>
<div class="wrapper">
	<div class="content" id="dietaryHabits-page">
		<div class="col-wrapper clearfix">
			<div class="info">
				<ul class="breadcrumb mb20">
					<li><a class="nohand">Personlige oplysninger</a></li>
					<li><a class="nohand">Dit abonnement</a></li>
					<li><a class="nohand">Book tid hos din vejleder</a></li>
					<li class="active"><a>Kostvaner/ ønsker</a></li>
					<li><a class="nohand">Motionsvaner/ ønsker</a></li>
				</ul>
				<form name="reg_form2" id="member-registration" action="index.php" method="post" class="form-validate" enctype="multipart/form-data">
					<h1 class="hd">Kostvaner/ ønsker</h1>
					<div class="colum bor mr27 fl m-h">
						<div class="col-wra">
							<div>Nuværende spisevaner:</div>
							<div>
								<label>Spiser du morgenmad regelmæssigt?</label>
							</div>
<?php if($breakfast){?>
	<div class="fr">
		<label class="uper">Ja/Nej</label>
		<input type="radio" class="ra" name="r1" value="1" checked>
		<input type="radio" class="ra" name="r1" value="">
	</div>
	<div id="opt1">
		<label class="fl ita w150">Hvis ja, hvad spiser du?</label>
		<input class="w86" name="jform[breakfast]" value="<?php echo $breakfast?>">
	</div>
<?php }else{?>
							<div class="fr">
								<label class="uper">Ja/Nej</label>
								<input type="radio" class="ra" name="r1" value="1">
								<input type="radio" class="ra" name="r1" value="" checked>
							</div>
							<div id="opt1" class="hide">
								<label class="fl ita w150">Hvis ja, hvad spiser du?</label>
								<input class="w86" name="jform[breakfast]">
							</div>
<?php }?>
						</div>
						<div class="col-wra">
							<div style="width: 210px;">
								<label>Drikker du sodavand?</label>
							</div>
<?php if($soda){?>
	<div class="fr">
		<label class="uper">Ja/Nej</label>
		<input class="ra" type="radio" name="r2" value="1" checked>
		<input class="ra" type="radio" name="r2" value="">
	</div>
	<div id="opt2">
		<label class="fl ita w150">Hvis ja, hvor meget ca. pr. dag?</label>
		<input class="w86" name="jform[soda]" value="<?php echo $soda?>">
	</div>
<?php }else{?>
							<div class="fr">
								<label class="uper">Ja/Nej</label>
								<input class="ra" type="radio" name="r2" value="1">
								<input class="ra" type="radio" name="r2" value="" checked>
							</div>
							<div id="opt2" class="hide">
								<label class="fl ita w150">Hvis ja, hvor meget ca. pr. dag?</label>
								<input class="w86" name="jform[soda]">
							</div>
<?php }?>
						</div>
						<div class="col-wra">
							<div style="width: 210px;">
								<label>Mener du, at du spiser nogenlunde <br> sundt</label>
							</div>
<?php if($eatwell){?>
	<div class="fr">
		<label class="uper">Ja/Nej</label>
		<input class="ra" type="radio" name="r3" value="1" checked>
		<input class="ra" type="radio" name="r3" value="">
	</div>
	<div id="opt3">
		<label class="fl ita" style="width: 182px">Hvor stor en procentdel af det du indtager, mener du er sundt?</label>
		&nbsp;<input name="jform[eatwell]" value="<?php echo $eatwell?>" style="width:22px;margin-left: 28px" maxlength="3">&nbsp;%
	</div>
<?php }else{?>
							<div class="fr">
								<label class="uper">Ja/Nej</label>
								<input class="ra" type="radio" name="r3" value="1">
								<input class="ra" type="radio" name="r3" value="" checked>
							</div>
							<div id="opt3" class="hide">
								<label class="fl ita w150">Hvor stor en procentdel af det du indtager, mener du er sundt?</label>
								&nbsp;<input name="jform[eatwell]" style="width:22px;margin-left: 60px">&nbsp;%
							</div>
<?php }?>
						</div>
						<div class="col-wra">
							<div>
								<label>Har du nogen form for spiseforstyrrelser</label><?php //rối loạn ăn uống, kén ăn?>
							</div>
<?php if($roiloan!=""){?>
	<div class="fr">
		<label class="uper">Ja/Nej</label>
		<input class="ra" type="radio" name="r4" value="1" checked>
		<input class="ra" type="radio" name="r4" value="">
	</div>
	<div class="clear"></div>
	<div id="opt4" class="" style="float: none">
		<div>
			<label>Hvis ja, har du fået eller får du hjælp?</label><?php //đã có ai giúp chưa?>
		</div>
		<div class="clear"></div>
		<div>
			<label class="uper">Ja/Nej</label>
			<input class="ra" type="radio" name="jform[roiloan]" value="1"<?php echo $roiloan=="1" ? " checked" : ""?>>
			<input class="ra" type="radio" name="jform[roiloan]" value="0"<?php echo $roiloan=="1" ? "" : " checked"?>>
		</div>
	</div>
<?php }else{?>
							<div class="fr">
								<label class="uper">Ja/Nej</label>
								<input class="ra" type="radio" name="r4" value="1">
								<input class="ra" type="radio" name="r4" value="" checked>
							</div>
							<div class="clear"></div>
							<div id="opt4" class="hide" style="float: none">
								<div>
									<label>Hvis ja, har du fået eller får du hjælp?</label><?php //đã có ai giúp chưa?>
								</div>
								<div class="clear"></div>
								<div class="fr">
									<label class="uper">Ja/Nej</label>
									<input class="ra" type="radio" name="jform[roiloan]" value="1">
									<input class="ra" type="radio" name="jform[roiloan]" value="0">
								</div>
							</div>
<?php }?>
						</div>
					</div>

					<div class="colum bor mr27 fl m-h">
						<div class="col-wra">
							<div>Mulige kostvaner:</div>
							<div>Hvornår på dagen har du mulighed for at spise</div>
							<div class="mb0">
								<div class="fl w100 mt25">Måltid 1:</div>
								<div class="fl">
									<label>Fra kl.</label>
									<select name="jform[meal1a]" class="w76">
										<option value="2">02</option>
										<option value="3">03</option>
										<option value="4" selected>04</option>
										<option value="5">05</option>
										<option value="6">06</option>
										<option value="7">07</option>
										<option value="8">08</option>
										<option value="9">09</option>
										<option value="10">10</option>
									</select>
								</div>
								<div class="fl ml7">
									<label>Til kl.</label>
									<select name="jform[meal1b]" class="w76">
										<option value="3">03</option>
										<option value="4">04</option>
										<option value="5">05</option>
										<option value="6">06</option>
										<option value="7">07</option>
										<option value="8">08</option>
										<option value="9">09</option>
										<option value="10">10</option>
										<option value="11" selected>11</option>
									</select>
								</div>
							</div>

							<div class="mb0">
								<div class="fl w100 mt8">Måltid 2:</div>
								<div class="fl">
									<select name="jform[meal2a]" class="w76">
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9" selected>9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
										<option value="13">13</option>
									</select>
								</div>
								<div class="fl ml7">
									<select name="jform[meal2b]" class="w76">
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
										<option value="13">13</option>
										<option value="14" selected>14</option>
									</select>
								</div>
							</div>

							<div class="mb0">
								<div class="fl w100 mt8">Måltid 3:</div>
								<div class="fl">
									<select name="jform[meal3a]" class="w76">
										<option value="11" selected>11</option>
										<option value="12">12</option>
										<option value="13">13</option>
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18">18</option>
									</select>
								</div>
								<div class="fl ml7">
									<select name="jform[meal3b]" class="w76">
										<option value="15">12</option>
										<option value="15">13</option>
										<option value="15">14</option>
										<option value="15">15</option>
										<option value="16" selected>16</option>
										<option value="17">17</option>
										<option value="18">18</option>
										<option value="19">19</option>
									</select>
								</div>
							</div>

							<div class="mb0">
								<div class="fl w100 mt8">Måltid 4:</div>
								<div class="fl">
									<select name="jform[meal4a]" class="w76">
										<option value="13" selected>13</option>
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18">18</option>
										<option value="19">19</option>
									</select>
								</div>
								<div class="fl ml7">
									<select name="jform[meal4b]" class="w76">
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18" selected>18</option>
										<option value="19">19</option>
										<option value="20">20</option>
									</select>
								</div>
							</div>

							<div class="mb0">
								<div class="fl w100 mt8">Måltid 5:</div>
								<div class="fl">
									<select name="jform[meal5a]" class="w76">
										<option value="14">14</option>
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17" selected>17</option>
										<option value="18">18</option>
										<option value="19">19</option>
										<option value="20">20</option>
										<option value="21">21</option>
										<option value="22">22</option>
									</select>
								</div>
								<div class="fl ml7">
									<select name="jform[meal5b]" class="w76">
										<option value="15">15</option>
										<option value="16">16</option>
										<option value="17">17</option>
										<option value="18">18</option>
										<option value="19">19</option>
										<option value="20">20</option>
										<option value="21" selected>21</option>
										<option value="22">22</option>
										<option value="23">23</option>
									</select>
								</div>
							</div>
						</div>

						<div class="col-wra">
							<p class="mt5">Er det vigtigt, at den kost du indtager, er varierende og smagsfuld?</p>
							<div>
								<input class="ra" type="radio" name="jform[diversity]" value="-1" checked=""> Ikke vigtigt<br class="mb10">
								<input class="ra" type="radio" name="jform[diversity]" value="1"> Meget vigtigt<br class="mb10">
								<input class="ra" type="radio" name="jform[diversity]" value="0"> Ingen af delene
							</div>
						</div>
					</div>

					<div class="colum bor fr m-h">
						<div>Mulige kostvaner:</div>
						<div>Hvor meget tid vil du ca. bruge<br>på at lave mad pr. dag?</div>
						<div class="fr">
							<select class="w76" name="jform[cooktime]" style="margin-left: 9px">
								<option value="0">0 min</option>
								<option value="30">30 min</option>
								<option value="45">45 min</option>
								<option value="60">60 min</option>
								<option value="90">90 min</option>
								<option value="120">2 timer</option>
								<option value="180">+3 timer</option>
							</select>
						</div>
						<div class="mt8">Hvilke fødevarer kan du lide?</div>
						<div class="clear"></div>
						<div class="w115 fl">
							<label class="w73 fl">Kylling</label>
							<input class="ck" type="checkbox" name="jform[fav][0]" value="Kylling"<?php echo (!isset($fav) OR $fav[0]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Rodfrugter</label>
							<input class="ck" type="checkbox" name="jform[fav][1]" value="Rodfrugter"<?php echo (!isset($fav) OR $fav[1]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Oksekød</label>
							<input class="ck" type="checkbox" name="jform[fav][2]" value="Oksekød"<?php echo (!isset($fav) OR $fav[2]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Chili</label>
							<input class="ck" type="checkbox" name="jform[fav][3]" value="Chili"<?php echo (!isset($fav) OR $fav[3]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Svinekød</label>
							<input class="ck" type="checkbox" name="jform[fav][4]" value="Svinekød"<?php echo (!isset($fav) OR $fav[4]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Proteinpulver</label>
							<input class="ck" type="checkbox" name="jform[fav][5]" value="Proteinpulver"<?php echo (!isset($fav) OR $fav[5]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Brune ris</label>
							<input class="ck" type="checkbox" name="jform[fav][6]" value="Brune ris"<?php echo (!isset($fav) OR $fav[6]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Æg</label>
							<input class="ck" type="checkbox" name="jform[fav][7]" value="Æg"<?php echo (!isset($fav) OR $fav[7]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Grønne bønner</label>
							<input class="ck" type="checkbox" name="jform[fav][8]" value="Grønne bønner"<?php echo (!isset($fav) OR $fav[8]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Fisk</label>
							<input class="ck" type="checkbox" name="jform[fav][9]" value="Fisk"<?php echo (!isset($fav) OR $fav[9]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Ost</label>
							<input class="ck" type="checkbox" name="jform[fav][10]" value="Ost"<?php echo (!isset($fav) OR $fav[10]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Nødder</label>
							<input class="ck" type="checkbox" name="jform[fav][11]" value="Nødder"<?php echo (!isset($fav) OR $fav[11]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl">
							<label class="w73 fl">Hakket kød<br>(svin/kalvekød/<br>okse)</label>
							<input class="ck" type="checkbox" name="jform[fav][12]" value="Hakket kød (svin/kalvekød/okse)"<?php echo (!isset($fav) OR $fav[12]) ? ' checked=""' : ""?>>
						</div>
						<div class="w115 fl ml30">
							<label class="w73 fl">Mælkeprodukter<br>(ymer, fromage<br>frais etc.)</label>
							<input class="ck" type="checkbox" name="jform[fav][13]" value="Mælkeprodukter (ymer, fromage frais etc.)"<?php echo (!isset($fav) OR $fav[13]) ? ' checked=""' : ""?>>
						</div>
						<div>Er du allergisk overfor nogle<br>fødevarer?</div>
<?php if($allergy){?>
	<div class="fr">
		<label class="uper">Ja/Nej</label>
		<input class="ra" type="radio" name="r5" value="1" checked>
		<input class="ra" type="radio" name="r5" value="">
	</div>
	<div class="clear"></div>
	<div id="opt5" style="float: none">
		<label class="fl ita w100">Hvis ja, hvad?</label>
		<input class="w86" name="jform[allergy]" value="<?php echo $allergy?>">
	</div>
<?php }else{?>

						<div class="fr">
							<label class="uper">Ja/Nej</label>
							<input class="ra" type="radio" name="r5" value="1">
							<input class="ra" type="radio" name="r5" value="" checked>
						</div>
						<div class="clear"></div>
						<div id="opt5" class="hide" style="float: none">
							<label class="fl ita w100">Hvis ja, hvad?</label>
							<input class="w86" name="jform[allergy]">
						</div>
<?php }?>
					</div>

					<div class="clear"></div>
					<a class="fr bntNext" onclick="document.reg_form2.submit();">Næste</a>
					<input type="hidden" name="option" value="com_users" />
					<input type="hidden" name="task" value="registration.step2" />
					<?php echo JHtml::_('form.token');?>
				</form>
			</div>
		</div>
	</div>
</div>
<!--    
 nam sua
!-->
<script type="text/javascript">
var f2=document.reg_form2;
	$(document).ready(function(){
		$("input[name=r1]").change(function() {
			if($(this).val())
				$("#opt1").show();
			else{
				$("#opt1").hide();
				f2.elements["jform[breakfast]"].value="";
			}
		});

		$("input[name=r2]").change(function() {
			if($(this).val())
				$("#opt2").show();
			else{
				$("#opt2").hide();
				f2.elements["jform[soda]"].value="";
			}
		});

		$("input[name=r3]").change(function() {
			if($(this).val())
				$("#opt3").show();
			else{
				$("#opt3").hide();
				f2.elements["jform[eatwell]"].value="";
			}
		});

		$("input[name=r4]").change(function() {
			if($(this).val())
				$("#opt4").show();
			else{
				$("#opt4").hide();
				f2.elements["jform[roiloan]"][0].checked=false;
				f2.elements["jform[roiloan]"][1].checked=false;
			}
		});


		$("input[name=r5 ]").change(function() {
			if($(this).val())
				$("#opt5").show();
			else{
				$("#opt5").hide();
				f2.elements["jform[allergy]"].value="";
			}
		});
	});
<?php
if($meal1a)
	echo 'f2.elements["jform[meal1a]"].value=',$meal1a,';';
if($meal1b)
	echo 'f2.elements["jform[meal1b]"].value=',$meal1b,';';
if($meal2a)
	echo 'f2.elements["jform[meal2a]"].value=',$meal2a,';';
if($meal2b)
	echo 'f2.elements["jform[meal2b]"].value=',$meal2b,';';
if($meal3a)
	echo 'f2.elements["jform[meal3a]"].value=',$meal3a,';';
if($meal3b)
	echo 'f2.elements["jform[meal3b]"].value=',$meal3b,';';
if($meal4a)
	echo 'f2.elements["jform[meal4a]"].value=',$meal4a,';';
if($meal4b)
	echo 'f2.elements["jform[meal4b]"].value=',$meal4b,';';
if($meal5a)
	echo 'f2.elements["jform[meal5a]"].value=',$meal5a,';';
if($meal5b)
	echo 'f2.elements["jform[meal5b]"].value=',$meal5b,';';
if($diversity!='')
	echo 'f2.elements["jform[diversity]"].value=',$diversity,';';
if($cooktime)
	echo 'f2.elements["jform[cooktime]"].value=',$cooktime,';';
?>
</script>